package com.sgg.jdkproxy.dynamicproxy.handle;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author ：brid
 * @date ：Created in 2021/5/19 13:55
 * @description：
 * @modified By：
 * @version: $
 */
public class MyInvocationHandler implements InvocationHandler {

    /**
     * 目标对象
     */
    private Object target;

    public MyInvocationHandler(Object target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("------前置通知代码-------");
        Object invoke = method.invoke(target);
        System.out.println("------后置通知代码-------");
        return invoke;
    }
}
